#pragma once
// MESSAGE FLIGHT_STATUS PACKING

#define MAVLINK_MSG_ID_FLIGHT_STATUS 180

MAVPACKED(
typedef struct __mavlink_flight_status_t {
 uint8_t flight_mode; /*<  flight mode*/
 uint8_t lock_state; /*<  lock state*/
 uint8_t gps_state; /*<  gps state*/
}) mavlink_flight_status_t;

#define MAVLINK_MSG_ID_FLIGHT_STATUS_LEN 3
#define MAVLINK_MSG_ID_FLIGHT_STATUS_MIN_LEN 3
#define MAVLINK_MSG_ID_180_LEN 3
#define MAVLINK_MSG_ID_180_MIN_LEN 3

#define MAVLINK_MSG_ID_FLIGHT_STATUS_CRC 240
#define MAVLINK_MSG_ID_180_CRC 240



#if MAVLINK_COMMAND_24BIT
#define MAVLINK_MESSAGE_INFO_FLIGHT_STATUS { \
    180, \
    "FLIGHT_STATUS", \
    3, \
    {  { "flight_mode", NULL, MAVLINK_TYPE_UINT8_T, 0, 0, offsetof(mavlink_flight_status_t, flight_mode) }, \
         { "lock_state", NULL, MAVLINK_TYPE_UINT8_T, 0, 1, offsetof(mavlink_flight_status_t, lock_state) }, \
         { "gps_state", NULL, MAVLINK_TYPE_UINT8_T, 0, 2, offsetof(mavlink_flight_status_t, gps_state) }, \
         } \
}
#else
#define MAVLINK_MESSAGE_INFO_FLIGHT_STATUS { \
    "FLIGHT_STATUS", \
    3, \
    {  { "flight_mode", NULL, MAVLINK_TYPE_UINT8_T, 0, 0, offsetof(mavlink_flight_status_t, flight_mode) }, \
         { "lock_state", NULL, MAVLINK_TYPE_UINT8_T, 0, 1, offsetof(mavlink_flight_status_t, lock_state) }, \
         { "gps_state", NULL, MAVLINK_TYPE_UINT8_T, 0, 2, offsetof(mavlink_flight_status_t, gps_state) }, \
         } \
}
#endif

/**
 * @brief Pack a flight_status message
 * @param system_id ID of this system
 * @param component_id ID of this component (e.g. 200 for IMU)
 * @param msg The MAVLink message to compress the data into
 *
 * @param flight_mode  flight mode
 * @param lock_state  lock state
 * @param gps_state  gps state
 * @return length of the message in bytes (excluding serial stream start sign)
 */
static inline uint16_t mavlink_msg_flight_status_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
                               uint8_t flight_mode, uint8_t lock_state, uint8_t gps_state)
{
#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
    char buf[MAVLINK_MSG_ID_FLIGHT_STATUS_LEN];
    _mav_put_uint8_t(buf, 0, flight_mode);
    _mav_put_uint8_t(buf, 1, lock_state);
    _mav_put_uint8_t(buf, 2, gps_state);

        memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_FLIGHT_STATUS_LEN);
#else
    mavlink_flight_status_t packet;
    packet.flight_mode = flight_mode;
    packet.lock_state = lock_state;
    packet.gps_state = gps_state;

        memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_FLIGHT_STATUS_LEN);
#endif

    msg->msgid = MAVLINK_MSG_ID_FLIGHT_STATUS;
    return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_FLIGHT_STATUS_MIN_LEN, MAVLINK_MSG_ID_FLIGHT_STATUS_LEN, MAVLINK_MSG_ID_FLIGHT_STATUS_CRC);
}

/**
 * @brief Pack a flight_status message on a channel
 * @param system_id ID of this system
 * @param component_id ID of this component (e.g. 200 for IMU)
 * @param chan The MAVLink channel this message will be sent over
 * @param msg The MAVLink message to compress the data into
 * @param flight_mode  flight mode
 * @param lock_state  lock state
 * @param gps_state  gps state
 * @return length of the message in bytes (excluding serial stream start sign)
 */
static inline uint16_t mavlink_msg_flight_status_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
                               mavlink_message_t* msg,
                                   uint8_t flight_mode,uint8_t lock_state,uint8_t gps_state)
{
#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
    char buf[MAVLINK_MSG_ID_FLIGHT_STATUS_LEN];
    _mav_put_uint8_t(buf, 0, flight_mode);
    _mav_put_uint8_t(buf, 1, lock_state);
    _mav_put_uint8_t(buf, 2, gps_state);

        memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_FLIGHT_STATUS_LEN);
#else
    mavlink_flight_status_t packet;
    packet.flight_mode = flight_mode;
    packet.lock_state = lock_state;
    packet.gps_state = gps_state;

        memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_FLIGHT_STATUS_LEN);
#endif

    msg->msgid = MAVLINK_MSG_ID_FLIGHT_STATUS;
    return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_FLIGHT_STATUS_MIN_LEN, MAVLINK_MSG_ID_FLIGHT_STATUS_LEN, MAVLINK_MSG_ID_FLIGHT_STATUS_CRC);
}

/**
 * @brief Encode a flight_status struct
 *
 * @param system_id ID of this system
 * @param component_id ID of this component (e.g. 200 for IMU)
 * @param msg The MAVLink message to compress the data into
 * @param flight_status C-struct to read the message contents from
 */
static inline uint16_t mavlink_msg_flight_status_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_flight_status_t* flight_status)
{
    return mavlink_msg_flight_status_pack(system_id, component_id, msg, flight_status->flight_mode, flight_status->lock_state, flight_status->gps_state);
}

/**
 * @brief Encode a flight_status struct on a channel
 *
 * @param system_id ID of this system
 * @param component_id ID of this component (e.g. 200 for IMU)
 * @param chan The MAVLink channel this message will be sent over
 * @param msg The MAVLink message to compress the data into
 * @param flight_status C-struct to read the message contents from
 */
static inline uint16_t mavlink_msg_flight_status_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_flight_status_t* flight_status)
{
    return mavlink_msg_flight_status_pack_chan(system_id, component_id, chan, msg, flight_status->flight_mode, flight_status->lock_state, flight_status->gps_state);
}

/**
 * @brief Send a flight_status message
 * @param chan MAVLink channel to send the message
 *
 * @param flight_mode  flight mode
 * @param lock_state  lock state
 * @param gps_state  gps state
 */
#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS

static inline void mavlink_msg_flight_status_send(mavlink_channel_t chan, uint8_t flight_mode, uint8_t lock_state, uint8_t gps_state)
{
#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
    char buf[MAVLINK_MSG_ID_FLIGHT_STATUS_LEN];
    _mav_put_uint8_t(buf, 0, flight_mode);
    _mav_put_uint8_t(buf, 1, lock_state);
    _mav_put_uint8_t(buf, 2, gps_state);

    _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_FLIGHT_STATUS, buf, MAVLINK_MSG_ID_FLIGHT_STATUS_MIN_LEN, MAVLINK_MSG_ID_FLIGHT_STATUS_LEN, MAVLINK_MSG_ID_FLIGHT_STATUS_CRC);
#else
    mavlink_flight_status_t packet;
    packet.flight_mode = flight_mode;
    packet.lock_state = lock_state;
    packet.gps_state = gps_state;

    _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_FLIGHT_STATUS, (const char *)&packet, MAVLINK_MSG_ID_FLIGHT_STATUS_MIN_LEN, MAVLINK_MSG_ID_FLIGHT_STATUS_LEN, MAVLINK_MSG_ID_FLIGHT_STATUS_CRC);
#endif
}

/**
 * @brief Send a flight_status message
 * @param chan MAVLink channel to send the message
 * @param struct The MAVLink struct to serialize
 */
static inline void mavlink_msg_flight_status_send_struct(mavlink_channel_t chan, const mavlink_flight_status_t* flight_status)
{
#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
    mavlink_msg_flight_status_send(chan, flight_status->flight_mode, flight_status->lock_state, flight_status->gps_state);
#else
    _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_FLIGHT_STATUS, (const char *)flight_status, MAVLINK_MSG_ID_FLIGHT_STATUS_MIN_LEN, MAVLINK_MSG_ID_FLIGHT_STATUS_LEN, MAVLINK_MSG_ID_FLIGHT_STATUS_CRC);
#endif
}

#if MAVLINK_MSG_ID_FLIGHT_STATUS_LEN <= MAVLINK_MAX_PAYLOAD_LEN
/*
  This varient of _send() can be used to save stack space by re-using
  memory from the receive buffer.  The caller provides a
  mavlink_message_t which is the size of a full mavlink message. This
  is usually the receive buffer for the channel, and allows a reply to an
  incoming message with minimum stack space usage.
 */
static inline void mavlink_msg_flight_status_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan,  uint8_t flight_mode, uint8_t lock_state, uint8_t gps_state)
{
#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
    char *buf = (char *)msgbuf;
    _mav_put_uint8_t(buf, 0, flight_mode);
    _mav_put_uint8_t(buf, 1, lock_state);
    _mav_put_uint8_t(buf, 2, gps_state);

    _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_FLIGHT_STATUS, buf, MAVLINK_MSG_ID_FLIGHT_STATUS_MIN_LEN, MAVLINK_MSG_ID_FLIGHT_STATUS_LEN, MAVLINK_MSG_ID_FLIGHT_STATUS_CRC);
#else
    mavlink_flight_status_t *packet = (mavlink_flight_status_t *)msgbuf;
    packet->flight_mode = flight_mode;
    packet->lock_state = lock_state;
    packet->gps_state = gps_state;

    _mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_FLIGHT_STATUS, (const char *)packet, MAVLINK_MSG_ID_FLIGHT_STATUS_MIN_LEN, MAVLINK_MSG_ID_FLIGHT_STATUS_LEN, MAVLINK_MSG_ID_FLIGHT_STATUS_CRC);
#endif
}
#endif

#endif

// MESSAGE FLIGHT_STATUS UNPACKING


/**
 * @brief Get field flight_mode from flight_status message
 *
 * @return  flight mode
 */
static inline uint8_t mavlink_msg_flight_status_get_flight_mode(const mavlink_message_t* msg)
{
    return _MAV_RETURN_uint8_t(msg,  0);
}

/**
 * @brief Get field lock_state from flight_status message
 *
 * @return  lock state
 */
static inline uint8_t mavlink_msg_flight_status_get_lock_state(const mavlink_message_t* msg)
{
    return _MAV_RETURN_uint8_t(msg,  1);
}

/**
 * @brief Get field gps_state from flight_status message
 *
 * @return  gps state
 */
static inline uint8_t mavlink_msg_flight_status_get_gps_state(const mavlink_message_t* msg)
{
    return _MAV_RETURN_uint8_t(msg,  2);
}

/**
 * @brief Decode a flight_status message into a struct
 *
 * @param msg The message to decode
 * @param flight_status C-struct to decode the message contents into
 */
static inline void mavlink_msg_flight_status_decode(const mavlink_message_t* msg, mavlink_flight_status_t* flight_status)
{
#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
    flight_status->flight_mode = mavlink_msg_flight_status_get_flight_mode(msg);
    flight_status->lock_state = mavlink_msg_flight_status_get_lock_state(msg);
    flight_status->gps_state = mavlink_msg_flight_status_get_gps_state(msg);
#else
        uint8_t len = msg->len < MAVLINK_MSG_ID_FLIGHT_STATUS_LEN? msg->len : MAVLINK_MSG_ID_FLIGHT_STATUS_LEN;
        memset(flight_status, 0, MAVLINK_MSG_ID_FLIGHT_STATUS_LEN);
    memcpy(flight_status, _MAV_PAYLOAD(msg), len);
#endif
}
